// Fill out your copyright notice in the Description page of Project Settings.

#pragma once
#define UDP_BUFFER_SIZE 1024
#define LOCAL_PORT 5566
#define REMOTE_PORT 7788

class FUdpExample : FRunnable
{
protected:
	FSocket* UdpSocket;
	FRunnableThread* ListenThread;
	FString DefaultSendTargetIp;
	int32 DefaultSendTargetPort;
	bool bIsReceiving;

	void StartListen();
	virtual uint32 Run() override;

public:
	FUdpExample();
	virtual ~FUdpExample() override;

	void SetSendDefaultTargetAddr(const FString& Ip = "127.0.0.1", const int32 Port = REMOTE_PORT);
	void SendMsg(const FString& Msg) const;
	void SendMsg(const FString& Msg, const FString& Ip, const int32 Port) const;
	void Close();
};
